package jok.poker;

public class APoker implements Comparable<APoker> {

	private int color;

	private String colorText;

	private int value;

	private String valueText;

	public int getColor() {
		return color;
	}

	public void setColor(int color) {
		this.color = color;

		switch (color) {
		case 0:
			this.colorText = "王";
			break;
		case 1:
			this.colorText = "♠";
			break;
		case 2:
			this.colorText = "♥";
			break;
		case 3:
			this.colorText = "♣";
			break;
		case 4:
			this.colorText = "♦";
			break;
		}
	}

	public String getColorText() {
		return colorText;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;

		switch (value) {
		case 1:
			this.valueText = "A";
			break;
		case 11:
			this.valueText = "J";
			break;
		case 12:
			this.valueText = "Q";
			break;
		case 13:
			this.valueText = "K";
			break;
		case 14:
			this.valueText = "大";
			break;
		case 15:
			this.valueText = "小";
			break;
		default:
			if (value >= 2 && value <= 10) {
				this.valueText = value + "";
			}
			break;
		}
	}

	public String getValueText() {
		return valueText;
	}

	public APoker(int color, int value) {
		super();
		this.setColor(color);
		this.setValue(value);
	}

	@Override
	public String toString() {
		return "APoker [color=" + color + ", colorText=" + colorText
				+ ", value=" + value + ", valueText=" + valueText + "]";
	}

	@Override
	public int hashCode() {
		return 1;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof APoker) {
			APoker ap = (APoker) obj;
			return compareTo(ap) == 0;
		}
		return super.equals(obj);
	}

	@Override
	public int compareTo(APoker o) {
		int result = this.color - o.color;
		if (result == 0) {
			result = this.value - o.value;
		}
		return result;
	}
}
